package com.qf.six.ssm.service.manager.impl;

import com.qf.six.ssm.commen.exception.ServiceException;
import com.qf.six.ssm.commen.request.ManagerParam;
import com.qf.six.ssm.commen.vo.ResponseCode;
import com.qf.six.ssm.entity.Manager;
import com.qf.six.ssm.mapper.manager.ManagerMapper;
import com.qf.six.ssm.service.manager.ManagerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ZL
 */
@Service
public class ManagerServiceImpl implements ManagerService {
    @Resource
    ManagerMapper managerMapper;

    /**
     * 编辑功能
     */
    @Override
    public int update(ManagerParam param) {
        int count = managerMapper.update(param);
        if(count > 0){
            return count;
        } else {
            throw new ServiceException(ResponseCode.ERROR);
        }
    }

    /**
     * 根据uid进行假删除
     *
     */
    @Override
    public int falseDelete(Long uid) {
        int count = managerMapper.updateStatus(uid);
        if(count > 0){
            return count;
        } else {
            throw new ServiceException(ResponseCode.ERROR);
        }
    }

    /**
     * 注册功能
     */
    @Override
    public int register(ManagerParam managerParam) {
        int count = managerMapper.insert(managerParam);
        if(count > 0){
            return count;
        } else {
            throw new ServiceException(ResponseCode.ERROR);

        }
    }

    /**
     * 查询所有用户资料
     *
     */
    @Override
    public List<Manager> selectAllManager() {
        List<Manager> list = managerMapper.selectAllManager();
        if(list.size() > 0){
            return list;
        } else {
            throw new ServiceException(ResponseCode.ERROR);

        }
    }
}
